package com.formacion.ipartek.migracion.ddbb;

import java.io.File;

import org.apache.log4j.Logger;
import org.apache.log4j.PropertyConfigurator;

import com.formacion.ipartek.migracion.interfaces.InterfacePersonaDAO;
import com.ipartek.formacion.migracion.dao.TxtPersonaDAO;

/**
 * 
 * @author Fila3+1
 */
public class TxtDAOFactory extends DAOFactory {

	// Parametros configuracion del fichero
	private static final String RUTA = "data";
	private static final String FILE_NAME = "personas.txt";

	private static final Logger log = Logger.getLogger(TxtDAOFactory.class);

	// Constructor
	// ************************************************************************
	public TxtDAOFactory() {
		PropertyConfigurator.configure("config/log4j.properties");
	}

	// Metodos
	// ************************************************************************

	/**
	 * Conectar con el fichero txt
	 * 
	 * @return fichero abierto
	 */
	public static File conectar() {
		File f = null;
		try {
			f = new File(RUTA + "\\" + FILE_NAME);
		} catch (Exception e) {

			log.error("Error conectando fichero " + FILE_NAME + ":"
					+ e.getMessage());
		} finally {

			return f;
		}

	}

	@Override
	public InterfacePersonaDAO getInterfacePersonaDAO() {

		return new TxtPersonaDAO();
	}

}
